// =====================================================================
// <copyright file="StringsTest.cs" author="David R. Guindo">
// 	Copyright (C) 2013. All rights reserved.
// </copyright>
// =====================================================================
// This code is released under the terms of the Apache 2.0 license, 
// http://apache.org/licenses/LICENSE-2.0.html
// =====================================================================

namespace AppBlock.Core.Test
{
    using System.Collections.Generic;
    using Microsoft.VisualStudio.TestTools.UnitTesting;

    [TestClass]
    public class LazyListTest
    {
        [TestMethod]
        public void LazyList_Test()
        {
            var target = new LazyList<string>();
            Assert.IsNotNull(target);
            Assert.IsNotNull(target.List);
            target.List.Add("Test");
            Assert.AreEqual(target.List.Count, 1);
        }

        [TestMethod]
        public void LazyList_CtorParam_Test()
        {
            var target = new LazyList<string>(() => new List<string> {"Test1", "Test2"});
            Assert.IsNotNull(target);
            Assert.IsNotNull(target.List);
            Assert.AreEqual(target.List.Count, 2);
            Assert.AreEqual(target.List[0], "Test1");
            Assert.AreEqual(target.List[1], "Test2");
        }

        [TestMethod]
        public void LazyList_IsValueCreated_Test()
        {
            var target = new LazyList<string>();
            Assert.IsNotNull(target);
            Assert.AreEqual(target.IsValueCreated, false);
            Assert.IsNotNull(target.List);
            Assert.AreEqual(target.IsValueCreated, true);
        }
    }
}